package com.fy56.platform.goodsTracking.car.service.impl;

import com.dexcoder.dal.JdbcDao;
import com.dexcoder.dal.build.Criteria;
import com.fy56.platform.goodsTracking.car.mode.Ordersynchronize;
import com.fy56.platform.goodsTracking.car.mode.Upstreamcompany;
import com.fy56.platform.goodsTracking.car.service.OrderSynchronizeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by XTK on 2017-04-26.
 */
@Repository
public class OrderSynchronizeServiceImpl implements OrderSynchronizeService {

    @Autowired
    private JdbcDao jdbcDao_public;

    @Override
    public List<Ordersynchronize> listOrderSynchronize() {
        Criteria criteria = Criteria.select(Ordersynchronize.class)
                .desc("organizationcode");
        return jdbcDao_public.queryList(criteria);
        // return jdbcDao_GoodsTracked.queryListForSql("select * from Car_Set", CarSet.class);
    }

    @Override
    public List<Upstreamcompany> listUpstreamCompany(String organizationcode) {
        Criteria criteria = Criteria.select(Upstreamcompany.class)
                .where("Usetrack", new Object[]{"1"})
                .and("organizationcode", new Object[]{organizationcode})
                .desc("organizationcode");
        return jdbcDao_public.queryList(criteria);
        // return jdbcDao_GoodsTracked.queryListForSql("select * from Car_Set", CarSet.class);
    }


    @Override
    public void updateLastTime(String organizationcode, String endtime) {
        Criteria criteria = Criteria.update(Ordersynchronize.class)
                .set("lasttime", endtime)
                .where("organizationcode", new Object[]{organizationcode});
        jdbcDao_public.update(criteria);
    }


}
